﻿/*
 *
 * @author
 * @version
 */
 class ClassData {
	function ClassData(){
	}
	
	public function execute(i:ClassInfo):Array {
		if (i == null) return null;
		var c:Function = i.getType();
		if (!c) return null;
		this.i = i;
		this.r = new Array();
		
		this.s = true;
		_global.ASSetPropFlags(c, null, 0, true);
		_global.ASSetPropFlags(c, ["__proto__", "constructor", "__constructor__", "prototype"], 1, true);
		search(c);
		
		this.s = false;
		var p:Object = c.prototype;
		_global.ASSetPropFlags(p, null, 0, true);
		_global.ASSetPropFlags(p, ["__proto__", "constructor", "__constructor__", "prototype"], 1, true);
		search(p);
		
		// ASSetPropFlags must be restored because unexpected behaviors get caused otherwise
		_global.ASSetPropFlags(c, null, 1, true);
		_global.ASSetPropFlags(p, null, 1, true);
		
		return r;
	}
	
	private function search(t):Void {
		var k:String;
		for (k in t) {
			if (typeof(t[k]) == "function"
					&& k.indexOf("__get__") < 0
					&& k.indexOf("__set__") < 0) {
				r[r.length] = new MethodInfo(k, i, s);
				r[k] = r[r.length-1];
			}
		}
	}
}